<include file="public/layout" />
<!--物流配置 css -start-->
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
<style>
    ul.group-list {
        width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
    }
    .err{color:#F00; display:none;}
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    .row .table-bordered td .btn,.row .table-bordered td img{
        vertical-align: middle;
    }
    .row .table-bordered td{
      padding: 8px;
      line-height: 1.42857143;
    }
    .table-bordered{
      width: 100%
    }
    .table-bordered tr td{
      border: 1px solid #f4f4f4;
    }
    .btn-success {
        color: #fff;background-color: #449d44;border-color: #398439 solid 1px;
    }
    .btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
}
.col-xs-8 {
    width: 66.66666667%;
}
.col-xs-4 {
    width: 33.33333333%;
}
.col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
    float: left;
}
.row .tab-pane h4{
  padding: 10px 0;
}
.row .tab-pane h4 input{
  vertical-align: middle;
} 
.table-striped>tbody>tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}
.ncap-form-default .title{
  border-bottom: 0
}
.ncap-form-default dl.row, .ncap-form-all dd.opt{
    /*border-color: #F0F0F0;*/
    border: none;
}
.ncap-form-default dl.row:hover, .ncap-form-all dd.opt:hover{
    border: none;box-shadow: inherit;
}
.addprine{display: inline; }
.alisth{margin-top: 10px}
.p_plus strong{cursor: pointer;margin-left: 4px;}
.freight_template {
    font-size: 14px;
    display: inline-block;
    padding: 0px 10px;
}
    .err{color:#F00; display:none;}
</style>
<!--物流配置 css -end-->
<!--以下是在线编辑器 代码 -->
<load href="__ROOT__/public/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/public/plugins/Ueditor/ueditor.all.min.js"/>
<script type="text/javascript" charset="utf-8" src="__ROOT__/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<!--以上是在线编辑器 代码  end-->
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商品设置</h3>
                <h5>商品基本信息设置</h5>
            </div>
            <ul class="tab-base nc-row">
                 <li><a href="{:U('sale/editsale',array('id'=>$brand.id))}" data-index='1' class="tab current"><span>通用信息</span></a></li>
                <li><a href="{:U('sale/photo',array('id'=>$brand.id))}" data-index='2' class="tab"><span>商品相册</span></a></li>
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>请务必正确填写商品信息</li>
        </ul>
    </div>
      <!--表单数据-->
    <form method="post" id="addEditGoodsForm">
       <input type="hidden" name="id" value="{$brand.id}">
        <input type="hidden" name="goods_id" value="{$goods.goods_id}">
        <!--通用信息-->

        <div class="ncap-form-default tab_div_1">
            <dl class="row">
              <dt class="tit">
                <label for="ac_name"><em>*</em>商品名称</label>
              </dt>
              <dd class="opt">
                <input type="text" placeholder="名称" class="input-txt" id="brand_name" name="sname" value="{$brand.sname}">
            <span class="err" id="err_name" style="color:#F00; display:none;"></span>
                  <p class="notic"></p>
              </dd>
            </dl>  
            <dl class="row">
                <dt class="tit"><em>*</em>
                    <label>起拍价</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$brand.shop_price}" name="shop_price" class="t_mane"
                           onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')"/>
                    <span class="err" id="err_market_price"></span>
                </dd>
            </dl>   
            <dl class="row">
                <dt class="tit"><em>*</em>
                    <label>保证金</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$brand.market_price}" name="market_price" class="t_mane"
                           onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')"/>
                    <span class="err" id="err_shop_price"></span>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit"><em>*</em>
                    <label>起拍价梯度</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$brand.add_price}" name="add_price" class="t_mane"
                           onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')"/>
                    <span class="err" id="err_shop_price"></span>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>竞价开始时间</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="start_time" name="starttime" value="{$brand.starttime|date='Y-m-d H:i:s',###}"  class="input-txt">
                    <span class="err" id="err_start_time"></span>
                    <p class="notic">竞价开始时间</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>竞价结束时间</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="end_time" name="endtime" value="{$brand.endtime|date='Y-m-d H:i:s',###}" class="input-txt">
                    <span class="err" id="err_end_time"></span>
                    <p class="notic">竞价结束时间</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>交货期</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="give_time" name="givetime" class="input-txt" value="{$brand.givetime}">
                    <span class="err" id="err_end_time"></span>
                    <p class="notic">商品交货期</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>用户名</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="user" class="input-txt" value="{$brand.user}">
                    <span class="err"></span>
                    <p class="notic">联系方式</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>手机号</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="phone" class="input-txt" value="{$brand.phone}">
                    <span class="err"></span>
                    <p class="notic">联系方式</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>委托协议的签订</label>
                </dt>
                <dd class="opt">
                    <div class="input-file-show">
                        <span class="show">
                                <a id="img_as" target="_blank" class="nyroModal" rel="gal" href="{$brand.pdu}">
                                    <i id="img_is" class="fa fa-picture-o"
                                       onMouseOver="layer.tips('<img src={$brand.pdu}>',this,{tips: [1, '#fff']});" onMouseOut="layer.closeAll();"></i>
                                </a>
                        </span>
                        <span class="type-file-box">
                            <input type="text" id="imagetexts" name="pdu" value="{$brand.pdu}" class="type-file-text">
                            <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                            <input class="type-file-file" onClick="GetUploadify(1,'','sale','img_call_backs')" size="30"
                                   title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                        </span>
                    </div>
                    <span class="err"></span>

                    <p class="notic">请上传图片格式文件</p>
                </dd>
              </dl>
            <dl class="row">
                <dt class="tit">
                    <label>商品图片上传</label>
                </dt>
                <dd class="opt">
                    <div class="input-file-show">
                        <span class="show">
                                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="{$brand.original_img}">  
                                    <i id="img_i" class="fa fa-picture-o"
                                       onMouseOver="layer.tips('<img src={$brand.original_img}>',this,{tips: [1, '#fff']});" onMouseOut="layer.closeAll();"></i>
                                </a>
                        </span>
                        <span class="type-file-box">
                            <input type="text" id="imagetext" name="original_img" value="{$brand.original_img}" class="type-file-text">
                            <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                            <input class="type-file-file" onClick="GetUploadify(1,'','sale','img_call_back')" size="30"
                                   title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                        </span>
                    </div>
                    <span class="err"></span>

                    <p class="notic">请上传图片格式文件</p>
                </dd>
              </dl>
              <dl class="row">
                  <dt class="tit">
                      <label>视频上传</label>
                  </dt>
                  <dd class="opt">
                      <div class="input-file-show">
                          <span class="type-file-box">
                              <input type="text" id="videotext" name="video" value="{$brand.video}" class="type-file-text">
                              <span id="video_button">
                                  <if condition="$brand.video">
                                      <input type="button" onclick="delupload()" value="删除视频" class="type-file-button">
                                      <else/>
                                      <input type="button" name="button" id="videobutton1" value="选择上传..." class="type-file-button">
                                      <input class="type-file-file" onClick="GetUploadify(1,'','sale','video_call_back','Flash')"
                                             size="30" title="点击按钮选择文件并提交表单后上传生效">
                                  </if>
                              </span>
                          </span>
                      </div>
                      <span class="err"></span>

                      <p class="notic">请上传视频格式文件</p>
                  </dd>
              </dl>                         
              <dl class="row">
                <dt class="tit">
                  <label for="ac_sort">排序</label>
                </dt>
                <dd class="opt">
                  <input type="text" placeholder="排序" name="sort" value="{$brand.sort}" maxlength="3" class="input-txt">
                  <span class="err" id="err_sort" style="color:#F00; display:none;"></span>
                    <p class="notic"></p>
                </dd>
              </dl>
              <dl class="row">
              <dt class="tit" colspan="2">
                <label class="" for="s_sort">所属分类</label>
              </dt>
              <dd class="opt">
                <div id="gcategory">
                 <select name="parent_cat_id" id="parent_id_1" onblur="get_categorys(this.value,'parent_id_2','0');"  onchange="get_categorys(this.value,'parent_id_2','0');" class="form-control" >
                      <option value="0">请选择分类</option> 
                      <foreach name="cat_list" item="v" >                                                                                     
                          <option value="{$v[id]}"  <if condition="$v[id] eq $brand[parent_cat_id]"> selected="selected" </if>>{$v[name]}</option>
                      </foreach>                                            
                  </select>
                <select name="cat_id" id="parent_id_2"  class="form-control" style="width:250px;"  onchange="get_categorys(this.value,'parent_id_3','0');" >
                  <option value="0">请选择分类</option>
                </select>
                <select name="cat_ids" id="parent_id_3"  class="form-control" style="width:250px;">
                  <option value="0">请选择分类</option>
                </select>
                <span  class="err" id="parent_cat_id" style="color:#F00; display:none;"></span>
                <span  class="err" id="cat_id" style="color:#F00; display:none;"></span>
                </div>
              </dd>
             </dl>
            <dl class="row">
              <dt class="tit">
                <label for="ac_name"><em>*</em>商品数量</label>
              </dt>
              <dd class="opt">
                <input type="text" class="input-txt" name="num" value="{$brand.num}">
              </dd>
            </dl>  
            <dl class="row">
                <dt class="tit">
                    <label for="record_no">商品重量</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$brand.weight}" name="weight" class="t_mane" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_weight" style="color:#F00; display:none;"></span>
                    <p class="notic"> 务必设置商品重量, 以克为单位</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>商品体积</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$brand.volume}"  name="volume" class="t_mane" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_volume" style="color:#F00; display:none;"></span>
                    <p class="notic"> 务必设置商品体积, 以立方米为单位</p>
                </dd>
            </dl>
            <dl class="row">
              <dt class="tit">
                <label for="ac_name"><em>*</em>供应商</label>
              </dt>
              <dd class="opt">
                <input type="text" class="input-txt" name="supply" value="{$brand.supply}">
              </dd>
            </dl>  
            <dl class="row">
              <dt class="tit">
                <label for="ac_name"><em>*</em>地址</label>
              </dt>
              <dd class="opt">
                <input type="text" class="input-txt" name="address" value="{$brand.address}">
              </dd>
            </dl>  
             <dl class="row">
                <dt class="tit">
                  <label for="ac_sort">商品描述</label>
                </dt>
                <dd class="opt">
                  <textarea  rows="50" cols="100" name="desc" class="span12">{$brand.desc}</textarea>
                </dd>
             </dl> 
             <dl class="row">
                <dt class="tit">
                  <label for="ac_sort">商品详情</label>
                </dt>
                <dd class="opt">
                  
                  <textarea rows="4" cols="60" name="info" class="span12 ckeditor" id="goods_content">{$brand.info}</textarea>
                  <span class="err" id="err_desc" style="color:#F00; display:none;"></span>                
                  <p class="notic"></p>
                </dd>
              </dl> 
        </div>

        <!--通用信息-->
        <!-- 商品相册-->
<!--     <div class="ncap-form-default tab_div_2" style="display:none;">
            <dl class="row">
                         <div class="tab-pane" id="tab_goods_images">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td>
                                    <volist name="goods['goods_images']" id="image">
                                        <div style="width:100px; text-align:center; margin: 5px; display:inline-block;" class="goods_xc">
                                            <input type="hidden" value="{$image['image_url']}" name="goods_images[]">
                                            <a onClick="" href="{$image['image_url']}" target="_blank"><img width="100" height="100" src="{$image['image_url']}"></a>
                                            <br>
                                            <a href="javascript:void(0)" onClick="ClearPicArr2(this,'{$image.image_url}')">删除</a>
                                        </div>
                                    </volist>

                                        <div class="goods_xc" style="width:100px; text-align:center; margin: 5px; display:inline-block;">
                                            <input type="hidden" name="goods_images[]" value="" />
                                            <a href="javascript:void(0);" onClick="GetUploadify(10,'','goods','call_back2');"><img src="/public/images/add-button.jpg" width="100" height="100" /></a>
                                            <br/>
                                            <a href="javascript:void(0)">&nbsp;&nbsp;</a>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
            </dl>             
        </div>  -->  
        <!-- 商品相册-->


    <div class="ncap-form-default">
            <div class="bot">            
                <a href="JavaScript:void(0);" id="submit" class="ncap-btn-big ncap-btn-green">确认提交</a>
                <span class="err" id="err_goods_id"></span>
            </div>
        </div>
     </form>
         <!--表单数据-->
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script>
   $(document).ready(function(){
        laydate.render({
            elem: '#start_time',//绑定元素
            theme: 'molv', //主题
            type:'datetime', //控件选择类型
            format: 'yyyy-MM-dd HH:mm:ss', //自定义格式
            calendar: true, //显示公历节日
            min:  'new Date()', //最小日期
            // value: new Date(),//默认当前时间
            isInitValue: true,
            position : 'fixed', //定位方式
            zIndex: 99999999, //css z-index
        });
        laydate.render({
            elem: '#end_time',//绑定元素
            theme: 'molv', //主题
            type:'datetime', //控件选择类型
            format: 'yyyy-MM-dd HH:mm:ss', //自定义格式
            calendar: true, //显示公历节日
             min: 'new Date()', //最小日期
            // value: new Date(),//默认当前时间
            isInitValue: true,
            position : 'fixed', //定位方式
            zIndex: 99999999, //css z-index
        });
        laydate.render({
            elem: '#give_time',//绑定元素
            theme: 'molv', //主题
            type:'datetime', //控件选择类型
            format: 'yyyy-MM-dd HH:mm:ss', //自定义格式
            calendar: true, //显示公历节日
             min: 'new Date()', //最小日期
            // value: new Date(),//默认当前时间
            isInitValue: true,
            position : 'fixed', //定位方式
            zIndex: 99999999, //css z-index
        });
    })


    //提交
    $(function(){
        $(document).on("click",'#submit',function(){
            var num = $('#parent_id_2').children('option').size();
            var nums = $('#parent_id_3').children('option').size();
            var parent_id = $("#parent_id_1").val();
            var name = $("#brand_name").val();
            var cat_id = $("#parent_id_2").val();
            var cat_ids = $("#parent_id_3").val();
            var time1 = $("#start_time").val(); 
            var time2 = $("#end_time").val(); 
            var time3 = $("#give_time").val(); 
            var t1 = new Date(time1);
            var t2 = new Date(time2);
            var t3 = new Date(time3);
            if (time1 == "" || time2 == "" || time3 == "") {
                layer.msg('请选择时间范围！', {icon: 2});return false;
                return false;
            }
            if((t2 - t1) <= 0){
                layer.msg('时间范围选择错误', {icon: 2});
                return false;
            }
            if((t3 - t2) <= 0){
                layer.msg('交货期不能小于拍卖结束时间', {icon: 2});
                return false;
            }
            if(parent_id == 0){
                layer.msg('所属分类必须选择！！', {icon: 2});return false;
            }
            if(cat_id == 0 && num != 1) {
                layer.msg('所属分类必须选择第二级！！', {icon: 2});return false;
            }
            if(cat_ids == 0 && nums != 1) {
                layer.msg('所属分类必须选择第三级！！', {icon: 2});return false;
            }
            $.ajax({
                type: "POST",
                url: "{:U('sale/editsale')}",
                data: $("#addEditGoodsForm").serialize(),
                async:false,
                dataType: "json",
                error: function () {
                    layer.alert("服务器繁忙, 请联系管理员!");
                },
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.msg,{icon: 1,time: 2000},function(){
                           location.href = "{:U('Daili/sale/index')}";
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2,time: 3000});
                    }
                }
            });
        })
    })

    window.onload = function(){
      var brand_cat_id = parseInt('{$brand.cat_id}');
      var brand_cat_ids = parseInt('{$brand.cat_ids}');
      if(brand_cat_id > 0 ){
        get_categorys($("#parent_id_1").val(),'parent_id_2',brand_cat_id);  
      } 
      if(brand_cat_ids > 0 ){
        get_categorys(brand_cat_id,'parent_id_3',brand_cat_ids);  
      }   
    }


     var url="{:url('daili/Ueditor/index',array('savePath'=>'sale'))}";
     var ue = UE.getEditor('goods_content',{
         toolbars: [[
             'fullscreen', 'source', '|', 'undo', 'redo', '|',
             'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
             'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
             'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
             'directionalityltr', 'directionalityrtl', 'indent', '|',
             'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
             'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
             'simpleupload', 'insertimage', 'emotion', 'scrawl', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
             'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
             'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
             'print', 'preview', 'searchreplace', 'drafts', 'help'
         ]],
         serverUrl :url,
         zIndex: 999,
         initialFrameWidth: "100%", //初化宽度
         initialFrameHeight: 300, //初化高度            
         focus: false, //初始化时，是否让编辑器获得焦点true或false
         maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
         pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
         autoHeightEnabled: true
     });
     
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
      $("#original_img2").attr('href', fileurl_tmp);
    }
 
    // 上传商品相册回调函数
    function call_back2(paths) {
        var last_div = $(".goods_xc:last").prop("outerHTML");
        for (var i = 0; i < paths.length; i++) {
            $(".goods_xc:eq(0)").before(last_div);  // 插入一个 新图片
            $(".goods_xc:eq(0)").find('a:eq(0)').attr('href', paths[i]).attr('onclick', '').attr('target', "_blank");// 修改他的链接地址
            $(".goods_xc:eq(0)").find('img').attr('src', paths[i]);// 修改他的图片路径
            $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick', "ClearPicArr2(this,'" + paths[i] + "')").text('删除');
            $(".goods_xc:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        }
    }
    //上传之后删除组图
    function ClearPicArr2(obj, path) {
        $.ajax({
            type: 'GET',
            url: "{:U('Admin/Uploadify/delupload')}",
            data: {action: "del", filename: path},
            success: function () {
                $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片
            }
        });
        // 删除数据库记录
        $.ajax({
            type: 'GET',
            url: "{:U('Admin/Goods/del_goods_images')}",
            data: {filename: path},
            success: function () {
            }
        });
    }

    // 属性输入框的加减事件
    function addAttr(a) {
        var attr = $(a).parent().parent().prop("outerHTML");
        attr = attr.replace('addAttr', 'delAttr').replace('+', '-');
        $(a).parent().parent().after(attr);
    }
    // 属性输入框的加减事件
    function delAttr(a) {
        $(a).parent().parent().remove();
    }



    //上传图片回调事件
    function img_call_back(fileurl_tmp) {
        $("#imagetext").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer.tips('<img src=" + fileurl_tmp + ">',this,{tips: [1, '#fff']});");
    }

    //上传图片回调事件
    function img_call_backs(fileurl_tmp) {
        $("#imagetexts").val(fileurl_tmp);
        $("#img_as").attr('href', fileurl_tmp);
        $("#img_is").attr('onmouseover', "layer.tips('<img src=" + fileurl_tmp + ">',this,{tips: [1, '#fff']});");
    }

    //上传视频回调事件
    function video_call_back(fileurl_tmp) {
        $("#videotext").val(fileurl_tmp);
        $("#video_a").attr('href', fileurl_tmp);
        $("#video_i").attr('onmouseover', "layer.tips('<img src=" + fileurl_tmp + ">',this,{tips: [1, '#fff']});");
        if (typeof(fileurl_tmp) != 'undefined') {
            $('#video_button').html('<input type="button" onclick="delupload()" value="删除视频" class="type-file-button" >');
        }
    }
    //删除上传图片事件
    function delupload() {
        $.ajax({
            url: "{:U('Uploadify/delupload')}",
            data: {url: $('#videotext').val()},
            success: function (data) {
                if (data == 1) {
                    layer.msg('删除成功！', {icon: 1});
                    $('#videotext').val('');
                    var html = '<input type="button" name="button" id="videobutton1" value="选择上传..." class="type-file-button"> <input class="type-file-file" onClick="GetUploadify(1,\'\',\'goods\',\'video_call_back\',\'Flash\')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击按钮选择文件并提交表单后上传生效">';
                    $('#video_button').html(html);
                } else {
                    layer.msg('删除失败', {icon: 2});
                }
            },
            error: function () {
                layer.msg('网络繁忙，请稍后再试!', {icon: 2});
            }
        })
    }
</script>
</body>
</html>